import { PetNewBaseView } from "../PetNewBaseView";
import { Language } from "../../../../../extend/language/Language";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { PetColor } from "../info/PetColor";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { PetUtil } from "../info/PetUtil";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { MsgManager } from "../../../manager/MsgManager";
import { PetSkillAlertWindow } from "./PetSkillAlertWindow";
import { PetExtendAlertWindow } from "./PetExtendAlertWindow";
import { Cache } from "../../../cache/Cache";
import { SkillConfig } from "../../../resource/SkillConfig";
import { DataEvent } from "../../../events/DataEvent";
import { PetItem } from "../PetItem";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { ObjCreate } from "../../common/ObjCreate";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DragEvent } from "../../../../../com/mui/events/DragEvent";
import { PetComboBoxItemCellRender } from "../changeModel/PetComboBoxItemCellRender";
import { PetModelPanel } from "../PetModelPanel";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { PublicMessageConfig } from "../../../resource/PublicMessageConfig";
import { PetExtendPreviewPanel } from "./PetExtendPreviewPanel";
import { SPetUpdate } from "../../../../../Message/Game/SPetUpdate";
import { GComboBox } from "../../../../../com/mui/controls/GComboBox";
type int = number;
//class PetExtendPanel
    
    export  class PetExtendPanel extends PetNewBaseView
    {
        constructor()
        {
            super();
            this._nameLString = Language.getString(54058);
            this._attNameArray = this._nameLString.split(",");
            this._attTxtArray = [];
            this._attNameTxtArray = [];
            this._labelTft = new GTextFormat(FontUtil.songtiName, 14, 6350622);
            this._valueTft = new GTextFormat(FontUtil.songtiName, 14, 15788607);
            Dispatcher.addEventListener(EventName.PetExtendSuccess, this.onPetExtendSuccessHandler);
            Dispatcher.addEventListener(EventName.PetExtendPreviewSuccess, this.onPetExtendPreviewSuccessHandler);
            Dispatcher.addEventListener(EventName.PetBagUpdate, this.onPetBagUpdateHandler);
            return;
        }

        /* internal  */updateMainByPetInfo(arg1: SPetInfo): void
        {
            this._mainPetInfo = arg1;
            if (arg1) 
            {
                this._mainPetItem.dragSource = arg1;
                this.updatePetSelected();
                this._mainPetComboBox.selectedIndex = this.getPetInComboIndex(arg1);
                this._mainPetComboBox.textColor = PetColor.getTalentColor(arg1).intColor;
            }
            this.updatePreviewByPetInfo();
            return;
        }

        /* internal  */updateDeputyByPetInfo(arg1: SPetInfo): void
        {
            this._deputyPetInfo = arg1;
            if (arg1) 
            {
                this._deputyPetItem.dragSource = arg1;
                this.updatePetSelected();
                this._deputyPetComboBox.selectedIndex = this.getPetInComboIndex(arg1);
                this._deputyPetComboBox.textColor = PetColor.getTalentColor(arg1).intColor;
            }
            this.updatePreviewByPetInfo();
            return;
        }

        /* internal  */updatePreviewByPetInfo(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc10=0;
            if (this._mainPetInfo && this._deputyPetInfo) 
            {
                this._previewPetItem.dragSource = this._mainPetInfo;
                this._previewNameTxt.htmlText = HTMLUtil.addColor(this._mainPetInfo.name, PetColor.getTalentColorByTalent(1, this.getMaxValue(this._mainPetInfo.talent, this._deputyPetInfo.talent)).color);
                loc1 = this.getPreviewInfoArray();
                loc4 = 0;
                while (loc4 < this._attTxtArray.length) 
                {
                    loc3 = this._attNameTxtArray[loc4];
                    loc3.visible = true;
                    loc2 = this._attTxtArray[loc4];
                    if (loc4 != 1) 
                    {
                        loc2.text = loc1[loc4].toString();
                    }
                    else 
                    {
                        loc2.text = Language.getStringByParam(28023, PetUtil.getRebornTimes(loc1[loc4]), PetUtil.getLevel(loc1[loc4]));
                    }
                    ++loc4;
                }
                loc5 = this.getMutiArray();
                loc7 = "";
                loc10 = 0;
                while (loc10 < loc5.length) 
                {
                    if ((loc6 = loc5[loc10] as int) > 0) 
                    {
                        loc8 = "↑";
                        loc9 = "#00ff00";
                    }
                    else if (loc6 != 0) 
                    {
                        loc8 = "↓";
                        loc9 = "#ff0000";
                    }
                    else 
                    {
                        loc8 = "";
                    }
                    if (loc6 == 0) 
                    {
                        loc7 = loc7 + "\n";
                    }
                    else 
                    {
                        if (loc10 == 1) 
                        {
                            loc6 = 90 - this._mainPetInfo.level + this._deputyPetInfo.level;
                        }
                        loc7 = loc7 + (loc8 + " " + Math.abs(loc6) + "\n");
                    }
                    ++loc10;
                }
                this._mutiTxt.htmlText = "<textFormat leading=\'11\'>" + HTMLUtil.addColor(loc7, loc9) + "</textFormat>";
                this._mutiTxt.visible = true;
                this._mainPetModel.updateModelByModelId(PetUtil.getShowModelId(this._mainPetInfo));
                this._mainPetModel.visible = true;
            }
            else 
            {
                this._previewPetItem.dragSource = null;
                this._previewNameTxt.htmlText = "";
                this._mutiTxt.visible = false;
                this.clearAttr();
                this._mainPetModel.visible = false;
            }
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var name: string;
            var onBtnClickHandler: Function;

            var loc1;
            e = arg1;
            name = (e.target as GButton).name;
            if (name != "extend") 
            {
                this.clear();
            }
            else if (this._previewPetItem.dragSource) 
            {
                if (!PetUtil.isPetCanExtend(this._mainPetInfo) || !PetUtil.isPetCanExtend(this._deputyPetInfo)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54062));
                    return;
                }
                if (PetUtil.hasEquips(this._deputyPetInfo)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54548));
                    return;
                }
                if (PetUtil.hasLifeStyle(this._deputyPetInfo)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54783));
                    return;
                }
                this._alertSkill = this.getAlertSkill();
                if (this._alertSkill.length > 0) 
                {
                    onBtnClickHandler = (arg1: string): void
                    {
                        if (arg1 == "ok") 
                        {
                            toAlertExtend();
                        }
                        return;
                    }
                    if (this._skillAlertWindow == null) 
                    {
                        this._skillAlertWindow = new PetSkillAlertWindow();
                    }
                    this._skillAlertWindow.petInfo = this._deputyPetInfo;
                    this._skillAlertWindow.setAlertSkill(this._alertSkill, onBtnClickHandler);
                    this._skillAlertWindow.show();
                }
                else 
                {
                    this.toAlertExtend();
                }
            }
            return;
        }

        /* internal  */toAlertExtend(): void
        {
            if (PetColor.isAbovePurple(this._deputyPetInfo.talent)) 
            {
                PetExtendAlertWindow.instance.mode = PetExtendAlertWindow.ValidateMode;
            }
            else 
            {
                PetExtendAlertWindow.instance.mode = PetExtendAlertWindow.NormalMode;
            }
            PetExtendAlertWindow.instance.mainPetInfo = this._mainPetInfo;
            PetExtendAlertWindow.instance.petInfo = this._deputyPetInfo;
            PetExtendAlertWindow.instance.show();
            if (Cache.instance.guide.guidePetMerge) 
            {
                PetExtendAlertWindow.instance.guidePetMerge();
            }
            return;
        }

        /* internal  */getAlertSkill(): Array<any>
        {
            var loc2=null;
            var loc3=null;
            var loc1=[];
            var loc4=0;
            while (loc4 < this._deputyPetInfo.skills.length) 
            {
                loc3 = this._deputyPetInfo.skills[loc4];
                loc2 = SkillConfig.instance.getInfoByName(loc3.skillId);
                if (loc2.skillLevel >= 2) 
                {
                    loc1.push(loc2);
                }
                ++loc4;
            }
            return loc1;
        }

        /* internal  */updatePetSelected(): void
        {
            if (Cache.instance.guide.guidePetMerge) 
            {
                this.dispatchEvent(new DataEvent(EventName.Guide_petMergeChange));
            }
            return;
        }

        /* internal  */clearAttr(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            while (loc3 < this._attTxtArray.length) 
            {
                loc1 = this._attTxtArray[loc3];
                loc2 = this._attNameTxtArray[loc3];
                loc2.visible = false;
                loc1.text = "";
                ++loc3;
            }
            return;
        }

        /* internal  */getPreviewInfoArray(): Array<any>
        {
            var loc1=[];
            if (this._mainPetInfo && this._deputyPetInfo) 
            {
                loc1.push(this.getMaxValue(this._mainPetInfo.talent, this._deputyPetInfo.talent));
                loc1.push(this.getMaxValue(PetUtil.getFourDigitLevel(this._mainPetInfo.reinLevel, this._mainPetInfo.level), PetUtil.getFourDigitLevel(this._deputyPetInfo.reinLevel, this._deputyPetInfo.level)));
                loc1.push(this.getMaxValue(this._mainPetInfo.growth, this._deputyPetInfo.growth));
                loc1.push(this.getMaxValue(this._mainPetInfo.spirit, this._deputyPetInfo.spirit));
            }
            return loc1;
        }

        /* internal  */getMutiArray(): Array<any>
        {
            var loc1=[];
            var loc2=this.getPreviewInfoArray();
            var loc3=[];
            loc3.push(this._mainPetInfo.talent);
            loc3.push(PetUtil.getFourDigitLevel(this._mainPetInfo.reinLevel, this._mainPetInfo.level));
            loc3.push(this._mainPetInfo.growth);
            loc3.push(this._mainPetInfo.spirit);
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc1.push(loc2[loc4] - loc3[loc4]);
                ++loc4;
            }
            return loc1;
        }

        /* internal  */getMaxValue(arg1: int, arg2: int): int
        {
            return arg1 >= arg2 ? arg1 : arg2;
        }

        /* internal  */onPetExtendSuccessHandler(arg1: DataEvent): void
        {
            this.clear();
            MsgManager.showRollTipsMsg(Language.getString(54063));
            return;
        }

        /* internal  */onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as PetItem).index;
            if (loc1 != 1) 
            {
                if (loc1 != 2) 
                {
                    if (loc1 == 3) 
                    {
                        this._previewPanel.x = 485;
                        this._previewPanel.y = 110;
                        if (this._previewPetItem.dragSource) 
                        {
                            if (this.secTimer == null) 
                            {
                                this.secTimer = new Object /* flash.utils.Timer */(500);
                                this.secTimer.repeatCount = 1;
                                this.secTimer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.onTimerCompleteHandler);
                            }
                            this.secTimer.reset();
                            this.secTimer.start();
                        }
                    }
                }
                else if (this._deputyPetInfo) 
                {
                    this._previewPanel.x = 515;
                    this._previewPanel.y = 65;
                    this._previewPanel.updateByPetInfo(this._deputyPetInfo);
                    this._previewPanel.visible = true;
                }
            }
            else if (this._mainPetInfo) 
            {
                this._previewPanel.x = 170;
                this._previewPanel.y = 65;
                this._previewPanel.updateByPetInfo(this._mainPetInfo);
                this._previewPanel.visible = true;
            }
            return;
        }

        /* internal  */onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._previewPanel.visible = false;
            return;
        }

        /* internal  */onTimerCompleteHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            this.secTimer.stop();
            if (this._mainPetInfo && this._deputyPetInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetExtendPreview, {"petMainUid": this._mainPetInfo.uid, "petDeputyUid": this._deputyPetInfo.uid}));
            }
            return;
        }

        /* internal  */onPetExtendPreviewSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPetInfo;
            this._previewPanel.updateByPetInfo(loc1);
            this._previewPanel.visible = true;
            return;
        }

        /* internal  */getPetComboDp(): DataProvider
        {
            var loc3=null;
            var loc1=new DataProvider();
            var loc2=Cache.instance.pet.petInfos;
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc3 = loc2[loc4] as SPetInfo;
                loc1.addItem({"label": loc3.name, "value": loc3});
                ++loc4;
            }
            return loc1;
        }

        /* internal  */resetComboBoxData(): void
        {
            this._petDp = this.getPetComboDp();
            this._mainPetComboBox.dataProvider = this._petDp;
            this._deputyPetComboBox.dataProvider = this._petDp;
            return;
        }

        /* internal  */onMainPetComboxChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._mainPetComboBox.selectedItem.value;
            this.moveInMainPet(loc1);
            return;
        }

        /* internal  */onDeputyPetComboxChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._deputyPetComboBox.selectedItem.value;
            this.moveInDeputyPet(loc1);
            return;
        }

        public guidePetMerge(arg1: Function): void
        {
            if (this._mainPetInfo) 
            {
                if (this._deputyPetInfo) 
                {
                    arg1(this._extendSprite.x + this._extendBtn.x, this._extendSprite.y + this._extendBtn.y, this._extendBtn, null, 3);
                }
                else 
                {
                    arg1(this._deputyPetItem.x, this._deputyPetItem.y, this._deputyPetItem, this._mainPetInfo, 2);
                }
            }
            else 
            {
                arg1(this._mainPetItem.x, this._mainPetItem.y, this._mainPetItem, this._deputyPetInfo, 1);
            }
            return;
        }

        /* internal  */moveInMainPet(arg1: SPetInfo): void
        {
            if (!PetUtil.isPetCanExtend(arg1)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54060));
                return;
            }
            if (this._deputyPetInfo && arg1 && arg1.uid == this._deputyPetInfo.uid) 
            {
                this.onDeputyPetItemClickHandler(null);
            }
            this.updateMainByPetInfo(arg1);
            return;
        }

        /* internal  */getPetInComboIndex(arg1: SPetInfo): int
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc1=-1;
            if (arg1) 
            {
                loc2 = this._mainPetComboBox.dataProvider.toArray();
                loc4 = 0;
                while (loc4 < loc2.length) 
                {
                    if ((loc3 = loc2[loc4].value as SPetInfo) && loc3.uid == arg1.uid) 
                    {
                        loc1 = loc4;
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        public clear(): void
        {
            this.onMainPetItemClickHandler(null);
            this.onDeputyPetItemClickHandler(null);
            this.clearAttr();
            this._previewPanel.visible = false;
            this._mainPetModel.visible = false;
            return;
        }

        protected /* override */ init(): void
        {
            var loc1=null;
            var loc2=null;
            this._petDp = this.getPetComboDp();
            ObjCreate.createFlowerBg(0, 0, 582, 303, this);
            ObjCreate.createBg(0, 305, 582, 95, this);
            this.addChild(new GImageBitmap("PetExtendBg.swf", 118, 10));
            ObjCreate.createTextField(Language.getString(54195), 85, 10, 70, 30, this, new GTextFormat(FontUtil.songtiName, 14, 15788607, true));
            ObjCreate.createBg(82, 28, 38, 38, this, ImagesConst.PackItemBg);
            this._mainPetItem = new PetItem();
            this._mainPetItem.index = 1;
            this._mainPetItem.setSize(32, 32);
            this._mainPetItem.move(84, 30);
            this._mainPetItem.addEventListener(DragEvent.Event_Move_In, this.onMainMoveInPetHandler);
            this._mainPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._mainPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._mainPetItem.addEventListener(flash.events.MouseEvent.CLICK, this.onMainPetItemClickHandler);
            this._mainPetItem.addEventListener(DragEvent.Event_Move_In, this.onMainMoveInPetHandler);
            this.addChild(this._mainPetItem);
            this._mainPetComboBox = ObjCreate.createGComboBox(53, 67, 95, 25, this._petDp, this);
            this._mainPetComboBox.selectedIndex = -1;
            this._mainPetComboBox.prompt = Language.getString(54559);
            this._mainPetComboBox.dropdown.setStyle("cellRenderer", PetComboBoxItemCellRender);
            this._mainPetComboBox.addEventListener(flash.events.Event.CHANGE, this.onMainPetComboxChangeHandler);
            ObjCreate.createTextField(Language.getString(54196), 440, 10, 70, 30, this, new GTextFormat(FontUtil.songtiName, 14, 15788607, true));
            ObjCreate.createBg(438, 28, 38, 38, this, ImagesConst.PackItemBg);
            this._deputyPetItem = new PetItem();
            this._deputyPetItem.index = 2;
            this._deputyPetItem.setSize(32, 32);
            this._deputyPetItem.move(440, 30);
            this._deputyPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._deputyPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._deputyPetItem.addEventListener(flash.events.MouseEvent.CLICK, this.onDeputyPetItemClickHandler);
            this._deputyPetItem.addEventListener(DragEvent.Event_Move_In, this.onDeputyMoveInPetHandler);
            this.addChild(this._deputyPetItem);
            this._deputyPetComboBox = ObjCreate.createGComboBox(407, 67, 95, 25, this._petDp, this);
            this._deputyPetComboBox.selectedIndex = -1;
            this._deputyPetComboBox.dropdown.setStyle("cellRenderer", PetComboBoxItemCellRender);
            this._deputyPetComboBox.prompt = Language.getString(54560);
            this._deputyPetComboBox.addEventListener(flash.events.Event.CHANGE, this.onDeputyPetComboxChangeHandler);
            this._extendSprite = new Object /* flash.display.Sprite */();
            this._extendSprite.x = 50;
            this._extendSprite.y = 110;
            this.addChild(this._extendSprite);
            this._extendSprite.addChild(new GImageBitmap("PetChangeModelBg.swf", 0, 0));
            this._extendSprite.addChild(new GImageBitmap("PetExtendPreviewLabel.png", -15, -10));
            this._mainPetModel = new PetModelPanel();
            this._mainPetModel.x = 85;
            this._mainPetModel.y = 140;
            this._mainPetModel.visible = false;
            this._extendSprite.addChild(this._mainPetModel);
            ObjCreate.createBg(215, 0, 38, 38, this._extendSprite, ImagesConst.PackItemBg);
            this._previewPetItem = new PetItem();
            this._previewPetItem.index = 3;
            this._previewPetItem.isDragAble = false;
            this._previewPetItem.isDropAble = false;
            this._previewPetItem.setSize(32, 32);
            this._previewPetItem.move(217, 2);
            this._previewPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._previewPetItem.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._extendSprite.addChild(this._previewPetItem);
            this._previewNameTxt = ObjCreate.createTextField("", 175, 50, 115, 20, this._extendSprite, GlobalStyle.textFormat6);
            this._previewNameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            var loc3=0;
            while (loc3 < 4) 
            {
                loc2 = ObjCreate.createTextField(this._attNameArray[loc3], 295, loc3 * 25, 60, 25, this._extendSprite, this._labelTft);
                loc2.visible = false;
                loc1 = ObjCreate.createTextField("", 335, loc3 * 25, 100, 25, this._extendSprite, this._valueTft);
                this._attNameTxtArray.push(loc2);
                this._attTxtArray.push(loc1);
                ++loc3;
            }
            this._mutiTxt = ObjCreate.createTextField("", 380, 0, 100, 100, this._extendSprite, this._valueTft);
            this._mutiTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._resetBtn = ObjCreate.createGButton(Language.getString(54061), 200, 75, 70, 28, this._extendSprite, "ButtonSpecial");
            this._extendBtn = ObjCreate.createGButton(Language.getString(54060), 200, 115, 70, 28, this._extendSprite, "ButtonSpecial");
            this._extendBtn.name = "extend";
            this._extendBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._resetBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            ObjCreate.createBitmap(ImagesConst.Fire, 175, 155, this._extendSprite);
            this._extendTipTxt = ObjCreate.createTextField("", 198, 162, 220, 20, this._extendSprite);
            this._extendTipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._extendTipTxt.htmlText = Language.getString(54561);
            super.init();
            updateTip(PublicMessageConfig.instance.getPetForgeTextByName("extendDesc"), 10, 315, 82);
            this._previewPanel = new PetExtendPreviewPanel();
            this._previewPanel.x = 485;
            this._previewPanel.y = 110;
            this._previewPanel.visible = false;
            this.addChild(this._previewPanel);
            return;
        }

        public /* override */ updateByPetInfo(arg1: SPetInfo): void
        {
            if (arg1) 
            {
                if (!PetUtil.isPetCanExtend(arg1)) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54062));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetCallBackAlert));
                    return;
                }
                if (this._mainPetInfo != null) 
                {
                    if (arg1.uid == this._mainPetInfo.uid) 
                    {
                        if (this._deputyPetInfo == null) 
                        {
                            this.updateDeputyByPetInfo(arg1);
                            this.onMainPetItemClickHandler(null);
                        }
                    }
                    else if (this._deputyPetInfo == null) 
                    {
                        this.updateDeputyByPetInfo(arg1);
                    }
                }
                else if (this._deputyPetInfo) 
                {
                    if (arg1.uid == this._deputyPetInfo.uid) 
                    {
                        this.updateMainByPetInfo(arg1);
                        this.onDeputyPetItemClickHandler(null);
                    }
                    else 
                    {
                        this.updateMainByPetInfo(arg1);
                    }
                }
                else 
                {
                    this.updateMainByPetInfo(arg1);
                }
            }
            else 
            {
                this.clear();
            }
            return;
        }

        public /* override */ update(arg1: Object, ... rest): void
        {
            super.update(arg1, rest);
            this.clear();
            this.resetComboBoxData();
            return;
        }

        /* internal  */onMainMoveInPetHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as PetItem;
            if (loc1) 
            {
                if (loc1 && loc1 is PetItem) 
                {
                    loc2 = loc1.petInfo;
                    this.moveInMainPet(loc2);
                }
            }
            return;
        }

        public onPetBagUpdateHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPetUpdate;
            if (loc1.updateType != 4) 
            {
                if (loc1.updateType == 2) 
                {
                    if (this._mainPetInfo && this._mainPetInfo.uid == loc1.petInfo.uid) 
                    {
                        this.onMainPetItemClickHandler(null);
                    }
                    else if (this._deputyPetInfo && this._deputyPetInfo.uid == loc1.petInfo.uid) 
                    {
                        this.onDeputyPetItemClickHandler(null);
                    }
                }
            }
            else if (this._mainPetInfo && this._mainPetInfo.uid == loc1.petInfo.uid) 
            {
                this.updateMainByPetInfo(loc1.petInfo);
            }
            else if (this._deputyPetInfo && this._deputyPetInfo.uid == loc1.petInfo.uid) 
            {
                this.updateDeputyByPetInfo(loc1.petInfo);
            }
            return;
        }

        /* internal  */onMainPetItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._mainPetItem.dragSource = null;
            this._mainPetInfo = null;
            this.updatePreviewByPetInfo();
            this.updatePetSelected();
            this._mainPetComboBox.selectedIndex = -1;
            this._mainPetComboBox.textColor = GlobalStyle.color1Uint;
            return;
        }

        /* internal  */onDeputyMoveInPetHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as PetItem;
            if (loc1) 
            {
                if (loc1 && loc1 is PetItem) 
                {
                    loc2 = loc1.petInfo;
                    this.moveInDeputyPet(loc2);
                }
            }
            return;
        }

        /* internal  */moveInDeputyPet(arg1: SPetInfo): void
        {
            if (!PetUtil.isPetCanExtend(arg1)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54062));
                return;
            }
            if (this._mainPetInfo && arg1 && arg1.uid == this._mainPetInfo.uid) 
            {
                this.onMainPetItemClickHandler(null);
            }
            this.updateDeputyByPetInfo(arg1);
            return;
        }

        /* internal  */onDeputyPetItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._deputyPetItem.dragSource = null;
            this._deputyPetInfo = null;
            this.updatePreviewByPetInfo();
            this.updatePetSelected();
            this._deputyPetComboBox.selectedIndex = -1;
            this._deputyPetComboBox.textColor = GlobalStyle.color1Uint;
            return;
        }

        /* internal */ /* var */_extendSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_mainPetItem: PetItem;

        /* internal */ /* var */_mainPetComboBox: GComboBox;

        /* internal */ /* var */_mainPetModel: PetModelPanel;

        /* internal */ /* var */_deputyPetItem: PetItem;

        /* internal */ /* var */_deputyPetComboBox: GComboBox;

        /* internal */ /* var */_previewNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mutiTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_extendBtn: GButton;

        /* internal */ /* var */_resetBtn: GButton;

        /* internal */ /* var */_previewPanel: PetExtendPreviewPanel;

        /* internal */ /* var */_skillAlertWindow: PetSkillAlertWindow;

        /* internal */ /* var */_extendTipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mainPetInfo: SPetInfo;

        /* internal */ /* var */_deputyPetInfo: SPetInfo;

        /* internal */ /* var */_nameLString: string;

        /* internal */ /* var */_attNameArray: Array<any>;

        /* internal */ /* var */_attTxtArray: Array<any>;

        /* internal */ /* var */_attNameTxtArray: Array<any>;

        /* internal */ /* var */_labelTft: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_alertSkill: Array<any>;

        /* internal */ /* var */_petDp: DataProvider;

        /* internal */ /* var */secTimer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_previewPetItem: PetItem;

        /* internal */ /* var */_valueTft: Object /* flash.text.TextFormat */;
    }
